
function [sound_level, frequency_level] = voice_analysis(file,f_min,f_max)

[y, fs, nbits] = wavread(file);


x = 1.5 * fs;
sound_level=[0];
frequency_level=[0];
x+(fs/2)


while x+(fs/2) <= length(y)
   %get a chunk of the signal
   z = (x+fs/2); %
   h = (x-fs/2);
   chunk = y(h:z);
   
   
   %get sound level
   level = sum(chunk.^2);
   sound_level(length(sound_level)+1)=level;
   
   
   %do fft and get overall level in the defined frequency range...
   [YfreqDomain,frequencyRange] = positiveFFT(chunk',fs);
   
   %figure out how the frequencies are spaced
   number_samples = length(frequencyRange);
   highest_freq = frequencyRange(number_samples);
   spacing = highest_freq/number_samples;

  
   %figure out where at which index the f_min and f_max are located
   f1 = floor((f_min/spacing)+1)+1; %will return an index just above  f_min
   f2 = floor((f_max/spacing)+1)+1; %will return an index just above the f_max

   %isolating the section between f_min and f_max
   section = abs(YfreqDomain(f1:f2));
   
   %summing it
   f_level=sum(section.^2);
   frequency_level(length(frequency_level)+1)=f_level;
   
   %move to the next chunk
   x = x+fs/2;
   
   
end

